home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / os2 / ext2_200.zip / EXT2_SRC.ZIP / 32BITS / EXT2-OS2 / FSD32 / FS32_IOC.C < prev    next >
C/C++ Source or Header  |  1996-09-21  |  4KB  |  127 lines

  1. //
  2. // $Header: D:/32bits/ext2-os2/fsd32/RCS/fs32_ioctl.c,v 1.1 1996/09/21 22:25:20 Willm Exp Willm $
  3. //
  4.  
  5. // 32 bits Linux ext2 file system driver for OS/2 WARP - Allows OS/2 to
  6. // access your Linux ext2fs partitions as normal drive letters.
  7. // Copyright (C) 1995, 1996 Matthieu WILLM
  8. //
  9. // This program is free software; you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation; either version 2 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. #ifdef __IBMC__
  23. #pragma strings(readonly)
  24. #endif
  25.  
  26.  
  27. #define INCL_DOS
  28. #define INCL_DOSERRORS
  29. #define INCL_NOPMAPI
  30. #include <os2.h>
  31.  
  32. #include <os2/types.h>
  33. #include <os2/StackToFlat.h>
  34. #include <linux/fs.h>
  35. #include <os2/os2proto.h>
  36. #include <os2/fsd32.h>
  37. #include <os2/fsh32.h>
  38. #include <os2/DevHlp32.h>
  39. #include <os2/log.h>
  40. #include <os2/trace.h>
  41. #include <os2/errors.h>
  42. #include <os2/files.h>
  43. #include <os2/volume.h>
  44. #include <linux/fs_proto.h>
  45.  
  46. /*
  47.  * struct fs32_ioctl_parms {
  48.  *     PTR16          pDataLenInOut;
  49.  *     unsigned short lenData;
  50.  *     PTR16          pData;
  51.  *     PTR16          pParmLenInOut;
  52.  *     unsigned short lenParm;
  53.  *     PTR16          pParm;
  54.  *     unsigned short func;
  55.  *     unsigned short cat;
  56.  *     PTR16           psffsd;
  57.  *     PTR16           psffsi;
  58.  * };
  59.  */
  60. int FS32ENTRY fs32_ioctl(struct fs32_ioctl_parms *parms) {
  61.     unsigned short *pDataLenInOut;
  62.     unsigned short *pParmLenInOut;
  63.     PTR16           pvpfsi16;
  64.     PTR16           pvpfsd16;
  65.     struct sffsi32 *psffsi;
  66.     struct vpfsi32 *pvpfsi;
  67.     union  vpfsd32 *pvpfsd;
  68.  
  69.     int             rc;
  70.     int             rc2;
  71.  
  72.  
  73.     parms = __StackToFlat(parms);
  74.  
  75.     if (trace_FS_IOCTL) {
  76.         kernel_printf("FS_IOCTL pre-invocation : cat = 0x%0X, func = 0x%0X", parms->cat, parms->func);
  77.     }
  78.  
  79.     if ((rc = DevHlp32_VirtToLin(parms->psffsi, __StackToFlat(&psffsi))) == NO_ERROR) {
  80.         if ((rc = fsh32_getvolparm(psffsi->sfi_hVPB, __StackToFlat(&pvpfsi16), __StackToFlat(&pvpfsd16))) == NO_ERROR) {
  81.             if ((rc = DevHlp32_VirtToLin(pvpfsi16, __StackToFlat(&pvpfsi))) == NO_ERROR) {
  82.                 if ((rc = fsh32_devioctl(
  83.                                      0,
  84.                                      pvpfsi->vpi_hDEV,
  85.                                      psffsi->sfi_selfsfn, /* sfn */
  86.                                      parms->cat,
  87.                                      parms->func,
  88.                                      parms->pParm,
  89.                                      parms->lenParm,
  90.                                      parms->pData,
  91.                                      parms->lenData
  92.                                     )) == NO_ERROR) {
  93.                     kernel_printf("FS_IOCTL - fsh32_devioctl returned %d", rc);
  94.                      /*
  95.                      * Nothing ...
  96.                      */
  97.                 } else {
  98.                     kernel_printf("FS_IOCTL - fsh32_devioctl returned %d", rc);
  99.                 } /* FSH_DEVIOCTL failed */
  100.             } else {
  101.                 kernel_printf("FS_IOCTL - Error while thunking pvpfsi - rc = %d", rc);
  102.             }
  103.         } else {
  104.             kernel_printf("FS_IOCTL - FSH_GETVOLPARM returned %d", rc);
  105.         } /* FSH_GETVOLPARM failed */
  106.  
  107.         if (parms->pParmLenInOut.seg) {
  108.             if ((rc2 = DevHlp32_VirtToLin(parms->pParmLenInOut, __StackToFlat(&pParmLenInOut))) == NO_ERROR) {
  109.                 *pParmLenInOut = parms->lenParm;
  110.             }
  111.         }
  112.         if (parms->pDataLenInOut.seg) {
  113.             if ((rc2 = DevHlp32_VirtToLin(parms->pDataLenInOut, __StackToFlat(&pDataLenInOut))) == NO_ERROR) {
  114.                 *pDataLenInOut = parms->lenData;
  115.             }
  116.         }
  117.     } else {
  118.         kernel_printf("FS_IOCTL - error while thunking psffsi", rc);        
  119.     }
  120.  
  121.     if (trace_FS_IOCTL) {
  122.         kernel_printf("FS_IOCTL post-invocation : rc = %d", rc);
  123.     }
  124.  
  125.     return rc;
  126. }
  127.